/*點圖气泡图区别属性:_svg_type 1:点 2：气泡*/
//  ==========
//  = Point = 
//  ========== 
/*
 * 创建对象         var scatterplot = Scatterplot.createNew();
 * 设置labelid        scatterplot.Labelid("a");
 * 创建SVG            scatterplot.CreateSvg();
 * 绘制                   scatterplot.Draw();
 * 
 * 未来：
 *      ===;
 * */
! function() {
	var Scatterplot = Object.create(Object);
	Object.defineProperties(Scatterplot, {
		"CreateNew": {
			"value": function(v) {
				return FCreateNew();
			}
		}
	});

	function FCreateNew() {
		var scatterplot = Object.create(Scatterplot);
		scatterplot = {
			"_labelid": undefined,
			"_width": undefined,
			"_data": undefined,
			"_placement_legend": undefined,
			"_scale_type_x": undefined,
			"_scale_type_y": undefined,
			"_switch_x_transfrom": undefined,
			"_switch_y_transfrom": undefined,
			"_scale_type_x_ordinal_type": undefined,
			"_scale_type_x_range_type_range_array": undefined,
			"_scale_type_x_range_type_min": undefined,
			"_scale_type_x_range_type_max": undefined,
			"_scale_type_x_range_type_Points_n": undefined,
			"_scale_type_y_ordinal_type": undefined,
			"_scale_type_y_range_type_range_array": undefined,
			"_scale_type_y_range_type_min": undefined,
			"_scale_type_y_range_type_max": undefined,
			"_scale_type_y_range_type_Points_n": undefined,
			"_scale_type_y_range_type_Bands_p": undefined,
			"_scale_type_y_range_type_Bands_o": undefined,
			"_showbackground_x": undefined,
			"_showbackground_y": undefined,
			"_svg_type": undefined,
			"_bottomAxis": undefined,
			"ValueToProperty": function(value, name) {
				this[name] = value;
				return this;
			}
		};

		Object.defineProperties(scatterplot, {
			"Labelid": {
				"value": function(v) {
					this.ValueToProperty(v, "_labelid")
					return this;
				}
			},
			"Width": {
				"value": function(v) {
					this.ValueToProperty(v, "_width")
					return this;
				}
			},
			"Data": {
				"value": function(v) {
					this.ValueToProperty(v, "_data")
					return this;
				}
			},
			"Placement_legend": {
				"value": function(v) {
					this.ValueToProperty(v, "_placement_legend")
					return this;
				}
			},
			"Scale_type_x": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x")
					return this;
				}
			},
			"Scale_type_y": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y")
					return this;
				}
			},
			"Switch_x_transfrom": {
				"value": function(v) {
					this.ValueToProperty(v, "_switch_x_transfrom")
					return this;
				}
			},
			"Switch_y_transfrom": {
				"value": function(v) {
					this.ValueToProperty(v, "_switch_y_transfrom")
					return this;
				}
			},
			"Scale_type_x_ordinal_type": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_ordinal_type")
					return this;
				}
			},
			"Scale_type_x_range_type_range_array": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_range_type_range_array")
					return this;
				}
			},
			"Scale_type_x_range_type_min": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_range_type_min")
					return this;
				}
			},
			"Scale_type_x_range_type_max": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_range_type_max")
					return this;
				}
			},
			"Scale_type_x_range_type_Points_n": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_range_type_Points_n")
					return this;
				}
			},
			"Scale_type_x_range_type_Bands_p": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_x_range_type_Bands_p")
					return this;
				}
			},
			"Scale_type_x_range_type_Bands_o": {
				"value": function(v) {
					this.ValueToProperty(v, "_Scale_type_x_range_type_Bands_o")
					return this;
				}
			},
			"Scale_type_y_ordinal_type": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_ordinal_type")
					return this;
				}
			},
			"Scale_type_y_range_type_range_array": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_range_type_range_array")
					return this;
				}
			},
			"Scale_type_y_range_type_min": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_range_type_min")
					return this;
				}
			},
			"Scale_type_y_range_type_max": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_range_type_max")
					return this;
				}
			},
			"Scale_type_y_range_type_Points_n": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_range_type_Points_n")
					return this;
				}
			},
			"Scale_type_y_range_type_Bands_p": {
				"value": function(v) {
					this.ValueToProperty(v, "_scale_type_y_range_type_Bands_p")
					return this;
				}
			},
			"Scale_type_y_range_type_Bands_o": {
				"value": function(v) {
					this.ValueToProperty(v, "_Scale_type_y_range_type_Bands_o")
					return this;
				}
			},
			"Showbackground_x": {
				"value": function(v) {
					this.ValueToProperty(v, "_showbackground_x")
					return this;
				}
			},
			"Showbackground_y": {
				"value": function(v) {
					this.ValueToProperty(v, "_showbackground_y")
					return this;
				}
			},
			"BottomAxis": {
				"value": function(v) {
					this.ValueToProperty(v, "_bottomAxis")
					return this;
				}
			},
			"Svg_type": {
				"value": function(v) {
					this.ValueToProperty(v, "_svg_type")
					return this;
				}
			},
			"CreateSvg": {
				value: function() {
					CreateSvg_scatterplot(this);
					return this;
				}
			},
			"Draw": {
				value: function() {
					draw_scatterplot(this);
					return this;
				}
			}
		});

		function CreateSvg_scatterplot(scatterplot) {
			//createSvg之前先判断scatterplot各属性
			DetermineProperties_scatterplot(scatterplot);

			scatterplot.svg = d3.select("#" + scatterplot._labelid)
				.append("svg")
				//															.style("background", "red")
				.attr("id", scatterplot._svgid)
				//              .attr("preserveAspectRatio", "xMidYMid meet")
				//              .attr("viewBox", "0 0 " + scatterplot._width + " " + scatterplot._height + " ");
				.attr("width", scatterplot._width)
				.attr("height", scatterplot._height);

			//              scatterplot.svg_ceshi1_g = scatterplot.svg.append("g").attr("id",scatterplot._svg_ceshi1_gid);
			//              scatterplot.svg_ceshi2_g = scatterplot.svg.append("g").attr("id",scatterplot._svg_ceshi2_gid);
			scatterplot.tool_window = d3.select("body")
				.append("div")
				.attr({
					"class": scatterplot._c_tool_window,
					"id": scatterplot._id_tool_window,
					"left": 0,
					"top": scatterplot._height,
				})
				.style({
					"opacity": 0
				})
		}

		function DetermineProperties_scatterplot(scatterplot) {
			SetId_scatterplot(scatterplot);
			scatterplot._height = scatterplot._width < 300 ? alert("width不能< 300") :
				(scatterplot._width / 0.618 * (1 - 0.618) < 500 ? scatterplot._width / 0.618 * (1 - 0.618) : 500);
			scatterplot._svg_type = 1;
			scatterplot._ToRight = 100;
			scatterplot._legend_length = 100;
			scatterplot._scatterplot_axis_x_length = scatterplot._width - scatterplot._ToRight - (scatterplot._placement_legend ? scatterplot._legend_length : 30);
			scatterplot._scale_type_x_range_type_min = 0;
			scatterplot._scale_type_x_range_type_max = scatterplot._scatterplot_axis_x_length;
			scatterplot._scale_type_y_range_type_min = 0;
			scatterplot._scale_type_y_range_type_max = scatterplot._height - 100;
			//						scatterplot._showbackground_x = scatterplot._switch_x_transfrom ? false : scatterplot._showbackground_x;
			//						scatterplot._showbackground_y = scatterplot._switch_y_transfrom ? false : scatterplot._showbackground_y;

		}

		function draw_scatterplot(scatterplot) {
			Tool_scatterplot(scatterplot);
			DataPretreatment_scatterplot(scatterplot);
			d3.selectAll("." + scatterplot._axis_x_class)[0][0] == null && scatterplot.svg.append("g")
				.attr("class", scatterplot._axis_x_class)
				.attr("transform", "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50 + scatterplot._switch_x_transfrom * (scatterplot.axis_y_scale(0))) + ")")
				.call(scatterplot.axis_x)
				.style("font-size", "12px")
			d3.selectAll("." + scatterplot._axis_y_class)[0][0] == null && scatterplot.svg.append("g")
				.attr("class", scatterplot._axis_y_class)
				.attr("transform", "translate(" + (scatterplot._ToRight + scatterplot._switch_y_transfrom * (scatterplot.axis_x_scale(0))) + "," + (scatterplot._height - 50) + ")")
				.call(scatterplot.axis_y)
				.style("font-size", "12px");
			var maxlength = [];
			d3.selectAll("." + scatterplot._axis_y_class).selectAll("text")[0].map(function(d) {
				maxlength.push(d.getComputedTextLength());
			});
			//"+(100 - 12- d3.max(maxlength)) +"
			scatterplot.g_title_x = scatterplot.svg.append("g")
				.attr({
					"class": scatterplot._c_g_title_x,
					"id": scatterplot._id_g_title_x,
					"transform": "translate(" + (scatterplot._ToRight + scatterplot._scatterplot_axis_x_length / 2) + "," + (scatterplot._height - 20) + ")"
				})
			scatterplot.title_x_updata = scatterplot.g_title_x.selectAll("." + scatterplot._c_g_title_x).data(["x轴/cm"]);
			scatterplot.title_x_enter = scatterplot.title_x_updata.enter();
			scatterplot.title_x_exit = scatterplot.title_x_updata.exit();
			scatterplot.g_title_y = scatterplot.svg.append("g")
				.attr({
					"class": scatterplot._c_g_grid_y_axis,
					"id": scatterplot._id_g_grid_y_axis,
					"transform": "translate(" + (100 - 12 - d3.max(maxlength)) + " ," + (scatterplot._height / 2) + ")"
				})
			scatterplot.title_y_updata = scatterplot.g_title_y.selectAll("." + scatterplot._c_g_title_y).data(["y轴/个"]);
			scatterplot.title_y_enter = scatterplot.title_y_updata.enter();
			scatterplot.title_y_exit = scatterplot.title_y_updata.exit();

			scatterplot.svg_legend_g = d3.selectAll("." + scatterplot._svg_legend_g_class)[0][0] == null && scatterplot.svg.append("g")
				.attr("class", scatterplot._svg_legend_g_class)
				.attr("id", scatterplot._svg_legend_g_id)
				.attr("transform", scatterplot._placement_legend ? "translate(" + scatterplot._width + ",0)" : "translate(0,0)");

			scatterplot.g_grid_x_axis = scatterplot.g_grid_x_axis || scatterplot.svg.append("g")
				.attr({
					"class": scatterplot._c_g_grid_x_axis,
					"id": scatterplot._id_g_grid_x_axis,
					"transform": "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50) + ")"
				})
			scatterplot.g_grid_y_axis = scatterplot.g_grid_y_axis || scatterplot.svg.append("g")
				.attr({
					"class": scatterplot._c_g_grid_y_axis,
					"id": scatterplot._id_g_grid_y_axis,
					"transform": "translate(" + (scatterplot._ToRight) + "," + (scatterplot._height - 50) + ")"
				})

			title(scatterplot);
			grid(scatterplot);
			point(scatterplot)
			legend(scatterplot);

			function title(scatterplot) {
				scatterplot.title_x_enter.append("text")
					.attr({
						"class": scatterplot._c_title_x,
						"id": scatterplot._id_title_x,
						"x": 0,
						"dx": 0,
						"y": 0,
						"dy": 0
					})
					.style("font-size", "12px")
					.text(function(d) {
						return d;
					})
				scatterplot.title_y_enter.append("text")
					.attr({
						"class": scatterplot._c_title_y,
						"id": scatterplot._id_title_y,
						"x": 0,
						"dx": 0,
						"y": 0,
						"dy": 0
					})
					.style({
						"font-size": "12px",
						"writing-mode": "tb"
					})
					.text(function(d) {
						return d;
					})

			}

			function grid(scatterplot) {
				scatterplot.grid_x = scatterplot.g_grid_x_axis.call(d3.svg.axis().scale(scatterplot.axis_x_scale).innerTickSize(-(scatterplot._height - 100)))
				scatterplot.grid_x.selectAll(".tick").selectAll("text").remove();
				scatterplot.grid_x.selectAll(".domain").remove()
				scatterplot.grid_x.selectAll("line")
					.attr("stroke-opacity", scatterplot._showbackground_x ? 1 : 0)
					.style("stroke-dasharray", [2, 1])
				scatterplot.grid_y = scatterplot.g_grid_y_axis.call(d3.svg.axis().scale(scatterplot.axis_y_scale).innerTickSize(-(scatterplot._scatterplot_axis_x_length)).orient("left"))
				scatterplot.grid_y.selectAll(".tick").selectAll("text").remove();
				scatterplot.grid_y.selectAll(".domain").remove()
				scatterplot.grid_y.selectAll("line")
					.style("stroke-opacity", scatterplot._showbackground_y ? 0.5 : 0)
					.style("stroke-dasharray", [2, 1])
			}
			/*
			 
			 * point 散点函数
			 * */
			function point(scatterplot) {
				scatterplot.svg_point_updata = scatterplot.svg.selectAll("#" + scatterplot._svg_point_class).data(scatterplot._data_.map(function(d) {
					return d;
				}))
				scatterplot.svg_point_enter = scatterplot.svg_point_updata.enter();
				scatterplot.svg_point_exit = scatterplot.svg_point_updata.exit();
				scatterplot.svg_point_enter
					.append("g")
					.attr("class", function(d, i) {

						return scatterplot._svg_point_g_class + i;
					})
					.attr("id", function(d, i) {
						return scatterplot._svg_point_g_id + i;
					})
					.attr("fill", function(d) {
						
						return scatterplot._scalecolor(d.name)
					})
					.attr("opacity", 0.6)
					//						    .attr("transform", "translate(" + 50 + "," + 670 + ")")
					.attr("transform", "translate(" + (scatterplot._ToRight /*- scatterplot._switch_y_transfrom * (scatterplot.axis_y_scale(0) -19)*/ ) + "," + (scatterplot._height - 50 /*-  scatterplot._switch_x_transfrom * (scatterplot.axis_x_scale(0) - 19)*/ ) + ")")

				.selectAll("circle")
					.data(function(d, i) {
						return d;
					})
					.enter()
					.append("circle")
					.attr({
						"class": function(d, i) {
							return scatterplot._svg_point_class + d.i + i;
						},
						"id": function(d, i) {
							return scatterplot._svg_point_id + d.i + i;
						},
						"cx": function(d) {
							return scatterplot._bottomAxis == "x" ? scatterplot.axis_x_scale(d[0]) : scatterplot.axis_x_scale(d[1])

						},
						"cy": function(d, i) {
							return scatterplot._bottomAxis == "x" ? scatterplot.axis_y_scale(d[1]) : scatterplot.axis_y_scale(d[0])
						},
						"r": function(d, i) {
							return scatterplot._svg_type == 1 ? "5px" : scatterplot.qipao_scale(d.weight);
						}
					})
					.on("mousemove", function(d) {
						scatterplot.tool_window.html("type:" + d.name + "<br />" + "x:" + d[0] + "<br />" + "y:" + d[1])
							.style("left", (d3.event.pageX) + "px")
							.style("top", (d3.event.pageY + 20) + "px")
							.style("opacity", 1.0)
					})
					.on("mouseout", function(d) {
						scatterplot.tool_window
							.html("")
							.style("left", "0px")
							.style("top", "0px")
							.style("opacity", 0.0)

					})

				//						        d3.selectAll("#"+ scatterplot._svg_point_g_id + i).data(scatterplot._data[i].value)
				//						    .append("cricle")
				//						    .attr("class",function (d,i) {
				//						        return scatterplot._svg_point_class + i;
				//						    })
				//						    .attr("id",function (d,i) {
				//						        return scatterplot._svg_point_id + i;
				//						    })
				//						    .attr({
				//						    	"rx": 100,
				//						    	"ry": 100,
				//						    	"r": 50
				//						    })

			}

			function legend(scatterplot) {
				scatterplot.svg_legend_logo_updata = scatterplot.svg_legend_g.selectAll("#" + scatterplot._svg_legend_logo_class).data(scatterplot._data_)
				scatterplot.svg_legend_logo_enter = scatterplot.svg_legend_logo_updata.enter();
				scatterplot.svg_legend_logo_exit = scatterplot.svg_legend_logo_updata.exit();
				scatterplot.svg_legend_logo_enter.append("circle")
					.attr({
						"class": function(d, i) {
							return scatterplot._svg_legend_logo_class + i;
						},
						"id": function(d, i) {
							return scatterplot._svg_legend_logo_id + i;
						},
						"cx": function(d, i) {
							return scatterplot._placement_legend ? (-10) : 110 + i * ((scatterplot._width - 100) / scatterplot._data_.length);

						},
						"cy": function(d, i) {
							return scatterplot._placement_legend ? (20 * i + 10) : 10;
						},
						"fill": function(d, i) {
							return scatterplot._scalecolor(d.name);
						},
						"r": function(d, i) {
							return "5px";

						}
					});

				scatterplot.svg_legend_text_updata = scatterplot.svg_legend_g.selectAll("#" + scatterplot._svg_legend_text_class).data(scatterplot._data_)
				scatterplot.svg_legend_text_enter = scatterplot.svg_legend_text_updata.enter();
				scatterplot.svg_legend_text_exit = scatterplot.svg_legend_text_updata.exit();
				scatterplot.svg_legend_text_enter.append("text")
					.attr({
						"class": function(d, i) {
							return scatterplot._svg_legend_text_class + i;
						},
						"id": function(d, i) {
							return scatterplot._svg_legend_text_id + i;
						},
						"x": function(d, i) {
							return scatterplot._placement_legend ? -(10 + 5) : 115 + i * ((scatterplot._width - 100) / scatterplot._data_.length);

						},
						"y": function(d, i) {
								return scatterplot._placement_legend ? (20 * i + 10 + 5) : 10 + 5;
							} //,

						//									"r": function(d, i) {
						//										return "5px";
						//
						//									}
					})
					.text(function(d, i) {
						return d.name
					})
					.style("text-anchor", scatterplot._placement_legend ? "end" : "start")
			}

		}

		function Tool_scatterplot(scatterplot) {
			scatterplot._scalecolor = d3.scale.category10();

			scatterplot.qipao_scale = scatterplot._svg_type == 2 && a(scatterplot);

			function a(scatterplot) {
				scale = d3.scale.linear();
				var max = [],
					min = [];
				scatterplot._data.map(function(d) {
					max.push(d3.max(d.weight.map(function(d) {
						return d
					})))
					min.push(d3.min(d.weight.map(function(d) {
						return d
					})))
				})
				var domain = [d3.min(min), d3.max(max)]
				scale.domain(domain); //数值中的元素依旧是数组。但是实际需要时每个元素的第一个值来衡量。scatterplot._data，function(d){reture d[1]};设置无效。
				scale.rangeRound([5, 10])
				return scale;
			}

		}

		function DataPretreatment_scatterplot(scatterplot) {
			scatterplot._data_ = []; //scatterplot._data_ = 
			scatterplot._data.map(function(d, i) {
				var a = [];
				d.value.map(function(q, j) {

					var b = q;
					b.name = d.name;
					b.weight = d.weight[j];
					d.i = i;
					a.push(b);
				})
				a.name = d.name;
				scatterplot._data_.push(a);
			})
			scatterplot._scalecolor();
			//						scatterplot._data.map(function(d, i) {
			//							scatterplot._scalecolor(d[0].name);
			//						})

			Package_scale(scatterplot, "x");
			Package_scale(scatterplot, "y");
			//						Package_scatterplot(scatterplot);
		}

		function Package_scatterplot(scatterplot) {

		}

		function Package_scale(scatterplot, object) {
			var scale;
			var array = ["_scale_type_" + object, //0
				"_scale_type_" + object + "_ordinal_type", //1
				"_scale_type_" + object + "_range_type_range_array", //2
				"_scale_type_" + object + "_range_type_min", //3
				"_scale_type_" + object + "_range_type_max", //4
				"_scale_type_" + object + "_range_type_Points_n", //5
				"_scale_type_" + object + "_range_type_Bands_p", //6
				"_scale_type_" + object + "_range_type_Bands_o", //7
				"_axis_" + object + "_data", //8
				"axis_" + object + "_scale", //9
				"axis_" + object, //10
				"_showbackground_" + object, //11,
				"axis_" + object + "_grid"
			];

			if(scatterplot[array[0]] == 1) {
				scale = d3.scale.linear();
				var max = [],
					min = [];
				scatterplot._data_.map(function(d) {
					max.push(d3.max(d.map(function(d) {
						return d[object == scatterplot._bottomAxis ? 0 : 1]
					})))
					min.push(d3.min(d.map(function(d) {
						return d[object == scatterplot._bottomAxis ? 0 : 1]
					})))
				})
				var domain = object == scatterplot._bottomAxis ? [d3.min(min), d3.max(max)] : [d3.min(min), d3.max(max)]
				//							scatterplot[array[8]] = Filterthedata(scatterplot._data, "data") /*[0].scatterplots*/ .map(function(d, i) {
				//
				//								return d[0][(object == "x" ? "x" : "value1")];
				//							}).sort(function(a, b) {
				//								return b - a;
				//							})
				var ceshi = domain.map(function(d, i) {

					if(i == 0) {
						var ii = 0;

						var f = d >= 0 ? 1 : -1;
						var num = Math.abs(d);
						while(num >= 10) {
							num = (num - (num % 10)) / 10;
							ii++;
						}
						var c = Math.pow(10, ii)
						var o = Math.ceil(Math.abs(d) / c)
						var shu = f > 0 ? (c == 1 ? 0 : f * o * c) : (c == 1 ? 10 * f : f * o * c);
						return shu;
					} else {
						//  ========== 
						//  = 此处不该纠结 = 
						//  ========== 
						var ii = 0;

						var f = d >= 0 ? 1 : -1;
						var num = Math.abs(d);
						while(num >= 10) {
							num = (num - (num % 10)) / 10;
							ii++;
						}
						var c = Math.pow(10, ii)
						var o = Math.ceil(Math.abs(d) / c)
						var shu = f > 0 ? (c == 1 ? 10 * f : f * o * c) : (c == 1 ? 0 : f * o * c);
						return shu;
					}
				});
				scale.domain(ceshi); 
				scale.rangeRound([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]])
			} else if(scatterplot[array[0]] == 2) {
				scale = d3.scale.ordinal();
				scatterplot[array[8]] = Filterthedata(scatterplot._data, "value") /*[0].scatterplots*/ .map(function(d, i) {
						return object == "x" ? d[0].name : d[0].value //[(object == "x" ? /*0 : 1*/ /*||*/ "x" : "y")];
					})
					/*.sort(function(a, b) {
					                            return a - b
					                        })*/
				if(scatterplot[array[1]] == 1) {
					scale.range(scatterplot[array[2]]);
				} else if(scatterplot[array[1]] == 2) {
					scale.rangeRoundPoints([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]], scatterplot[array[5]]);
				} else {
					scale.rangeRoundBands([(object == "x" ? 1 : -1) * scatterplot[array[3]], (object == "x" ? 1 : -1) * scatterplot[array[4]]], scatterplot[array[6]], scatterplot[array[7]])
				}
				scale.domain(scatterplot[array[8]]); //数值中的元素依旧是数组。但是实际需要时每个元素的第一个值来衡量。scatterplot._data，function(d){reture d[1]};设置无效。
			} else {
				scale = d3.time.scale();
			}

			scatterplot[array[9]] = scale;
			//						scatterplot[array[10]] = d3.svg.axis()
			//							.scale(scatterplot[array[9]])
			//							.tickSize(1)
			//							//                              .innerTickSize(object == "x" ? -3 : 3)
			//							.innerTickSize(object == "x" ? (scatterplot[array[11]] == true ? -scatterplot._height + 100 + scatterplot._switch_x_transfrom * (scatterplot.axis_x_scale(0) - 19) : -3) : (scatterplot[array[11]] == true ? -scatterplot._scatterplot_axis_x_length - scatterplot._switch_y_transfrom * (scatterplot.axis_y_scale(0) + 19) : 3))
			//							//							.outerTickSize(object == "x" ? (scatterplot[array[11]] == true ?  scatterplot._switch_x_transfrom * scatterplot.axis_x_scale(0) -19 : 0) : (scatterplot[array[11]] == true ? - scatterplot._switch_y_transfrom * scatterplot.axis_y_scale(0) +19 : 0))
			//							.orient(object == "x" ? "bottom" : "left");
			scatterplot[array[10]] = d3.svg.axis()
				.scale(scatterplot[array[9]])
				.tickSize(1)
				.innerTickSize(3)
				.orient(object == "x" ? "bottom" : "left");
		}

		function Filterthedata(array, str) {
			var a = str.split("-");
			a.map(function(d, i) {
				array = array[d];
			})
			return array;
		}
		//  ========== 
		//  = 判断属性 = 
		//  ========== 
		function Detect_function_scatterplot(object_lh) {
			return typeof(object_lh) == "undefined";
		}

		function SetId_scatterplot(scatterplot) {
			scatterplot._svgid = scatterplot._labelid + "svg";
			scatterplot._axis_x_class = scatterplot._labelid + "axis_x_class";
			scatterplot._axis_y_class = scatterplot._labelid + "axis_y_class";

			scatterplot._c_g_title_x = scatterplot._labelid + "_c_g_title_x"
			scatterplot._id_g_title_x = scatterplot._labelid + "_id_g_title_x"
			scatterplot._c_title_x = scatterplot._labelid + "_c_title_x"
			scatterplot._id_title_x = scatterplot._labelid + "_id_title_x"

			scatterplot._c_g_title_y = scatterplot._labelid + "_c_g_title_y"
			scatterplot._id_g_title_y = scatterplot._labelid + "_id_g_title_y"
			scatterplot._c_title_y = scatterplot._labelid + "_c_title_y"
			scatterplot._id_title_y = scatterplot._labelid + "_id_title_y"

			scatterplot._c_g_grid_x_axis = scatterplot._labelid + "_c_g_grid_x_axis";
			scatterplot._id_g_grid_x_axis = scatterplot._labelid + "_id_g_grid_x_axis";
			scatterplot._c_g_grid_y_axis = scatterplot._labelid + "_c_g_grid_y_axis";
			scatterplot._id_g_grid_y_axis = scatterplot._labelid + "_id_g_grid_y_axis";
			scatterplot._c_grid_x_axis = scatterplot._labelid + "_c_grid_x_axis";
			scatterplot._id_grid_x_axis = scatterplot._labelid + "_id_grid_x_axis";
			scatterplot._c_grid_y_axis = scatterplot._labelid + "_c_grid_y_axis";
			scatterplot._id_grid_y_axis = scatterplot._labelid + "_id_grid_y_axis";

			scatterplot._svg_point_g_class = scatterplot._labelid + "point_g_class";
			scatterplot._svg_point_g_id = scatterplot._labelid + "point_g_id";
			scatterplot._svg_point_class = scatterplot._labelid + "point_class";
			scatterplot._svg_point_id = scatterplot._labelid + "point_id";
			scatterplot._svg_legend_g_class = scatterplot._labelid + "legend_g_class";
			scatterplot._svg_legend_g_id = scatterplot._labelid + "legend_g_id";
			scatterplot._svg_legend_logo_class = scatterplot._labelid + "legend_logo_class";
			scatterplot._svg_legend_logo_id = scatterplot._labelid + "legend_logo_id";
			scatterplot._svg_legend_text_class = scatterplot._labelid + "legend_text_class";
			scatterplot._svg_legend_text_id = scatterplot._labelid + "legend_text_id";

			scatterplot._c_tool_g = scatterplot._labelid + "_c_tool_g";
			scatterplot._id_tool_g = scatterplot._labelid + "_id_tool_g";
			scatterplot._c_tool_line = scatterplot._labelid + "_c_tool_line";
			scatterplot._id_tool_line = scatterplot._labelid + "_id_tool_line";
			scatterplot._c_tool_window = "Tooltip";
			scatterplot._id_tool_window = scatterplot._labelid + "PiesTooltip_id";

		}
		return scatterplot;
	};
	this.Scatterplot = Scatterplot;
}();